/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import mockjs from 'mockjs';

const { mock } = mockjs;

export default {
  // 代入库，列表
  'POST /Api/YZ/League/complate': (req, res) => {
    const { page = 1, pageSize = 20 } = req.body;
    res.send(
      mock({
        code: 0,
        msg: '成功',
        data: {
          'list|10': [
            {
              cm_id: '@id',
              inn_name: '@cname',
              phone: '133****9999',
              'platform|1': ['申通', '圆通', '韵达', '圆通、中通'],
              update_time: '@date',
            },
          ],
          page,
          page_size: pageSize,
          total: 200,
        },
      }),
    );
  },
  // 代入库，详情
  'POST /Api/YZ/League/complateDetail': (req, res) => {
    const { cm_id } = req.body;

    const info = cm_id
      ? [
          {
            platform: '圆通',
            username: '15519505110',
            password: '1233',
            status: '0',
            sms_code: 0,
            platform_brand: ['zt'],
          },
          {
            platform: '中通',
            username: '15885370856',
            password: '4321',
            status: '1',
            sms_code: 0,
            platform_brand: [],
          },
          {
            platform: '多多',
            username: '15822220856',
            password: '4321123',
            status: '1',
            sms_code: 1,
            platform_brand: ['jt', 'yd'],
          },
        ]
      : [
          {
            platform: '韵达',
            username: '',
            password: '',
            status: 0,
            sms_code: 0,
            platform_brand: [],
          },
          {
            platform: '中邮',
            username: '',
            password: '',
            status: 0,
            sms_code: 0,
            platform_brand: [],
          },
          {
            platform: '多多',
            username: '',
            password: '',
            status: 0,
            sms_code: 1,
            platform_brand: [],
          },
        ];

    res.send(
      mock({
        code: 0,
        msg: '成功',
        data: {
          cm_id: cm_id ? '4322090' : '',
          inn_name: cm_id ? '水城玉舍镇' : '',
          phone: cm_id ? '191****8540' : '',
          info,
          platform_brand: {
            sto: '申通',
            zt: '中通',
            yt: '圆通',
            yd: '韵达',
            jt: '极兔',
            jz: '邮政',
            ems: 'EMS',
          },
        },
      }),
    );
  },
  // 代入库，新增修改
  'POST /Api/YZ/League/complateAdd': (req, res) => {
    const { data } = req.body;
    const arr = JSON.parse(data);
    const index = arr.findIndex(v => v.platform == '多多');
    const { sms_code } = arr.find(v => v.platform == '多多');
    res.send(
      mock({
        code: sms_code ? 0 : index > 0 ? 19999 : 1000,
        msg: '成功ssssss',
        data:
          index > 0
            ? {
                sms_code: '多多',
              }
            : {},
      }),
    );
  },
  // 代入库，导入
  'POST /Api/YZ/League/complateImport': (req, res) => {
    res.send(
      mock({
        code: 1110,
        msg: '导入成功',
        data: {},
      }),
    );
  },
  // 场地扫描管理，快递员列表
  'POST /Api/YZ/League/sitescan': (req, res) => {
    const { page = 1, pageSize = 20 } = req.body;
    res.send(
      mock({
        code: 0,
        msg: '成功',
        data: {
          'list|10': [
            {
              id: '@id',
              league_id: '@id',
              courier_id: '@id',
              create_at: '@datetime',
              update_at: '@datetime',
              'status|1': [0, 1],
              username: '15179185977',
              realname: '@cname',
            },
          ],
          page,
          page_size: pageSize,
          total: 200,
        },
      }),
    );
  },
  // 场地扫描管理，添加快递员
  'POST /Api/YZ/League/sitescanAdd': (req, res) => {
    res.send(
      mock({
        code: 0,
        msg: '成功',
        data: '',
      }),
    );
  },
  // 场地扫描管理，快递员启用/禁用
  'POST /Api/YZ/League/sitescanEdit': (req, res) => {
    res.send(
      mock({
        code: 0,
        msg: '成功',
        data: '',
      }),
    );
  },
  // 场地扫描管理，货架设置框数量详情
  'POST /Api/YZ/League/frameDetail': (req, res) => {
    res.send(
      mock({
        code: 0,
        msg: '成功',
        data: '@integer(1,1000)',
      }),
    );
  },
  // 场地扫描管理，货架框数量设置
  'POST /Api/YZ/League/frameEdit': (req, res) => {
    res.send(
      mock({
        code: 0,
        msg: '成功',
        data: '',
      }),
    );
  },
  // 代入库，发送短信
  'POST /Api/YZ/League/sendSmsCode': (req, res) => {
    res.send(
      mock({
        code: 0,
        msg: '发送成功',
        data: {},
      }),
    );
  },
};
